package com.ww.learn.funs

fun main() {
    val numbers = mutableListOf("one", "two", "three", "four")
    val countEndsWithE = numbers.run {
        add("five")
        add("six")
        count { it.endsWith("e") }
    }
    println("There are $countEndsWithE elements that end with e")

    // 还可以忽略返回值，仅使用作用域函数作为局部变量创建一个临时作用域
    with (numbers) {
        val firstItem = first()
        val lastItem = last()
        println("First item: $firstItem, Last item: $lastItem")
    }
}